﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;

namespace WhileAwayWpf
{
    [Serializable]
    public class AwayMessage : INotifyPropertyChanged
    {
        private string _sender;
        private string _message;
        private bool _isPrivate;
        private DateTime _when;

        public string Sender
        {
            get { return _sender; }
            set { _sender = value; PropChanged("Sender"); }
        }

        public string Message
        {
            get { return _message; }
            set { _message = value; PropChanged("Message"); }
        }

        public bool IsPrivate
        {
            get { return _isPrivate; }
            set { _isPrivate = value; PropChanged("IsPrivate"); }
        }

        public DateTime When
        {
            get { return _when; }
            set { _when = value; PropChanged("When"); }
        }

        public override string ToString()
        {
            return string.Format("[{0:t}] {1} by {2}",
                _when, _message, _sender);
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;
        private void PropChanged(string prop)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(prop));
        }
        #endregion
    }
}
